package com.wwtech.epp.ui.adapter.work;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wwtech.epp.R;
import com.wwtech.epp.entity.ApproveState;
import com.wwtech.epp.utils.WorkUtil;
import com.wwtech.epp.view.GlideCircleTransform;

import java.util.List;

/**
 * Created by hu on 2017/10/15.
 */

public class ApproveStateAdapter extends BaseQuickAdapter<ApproveState.DataBean.ReviewStatusBean, BaseViewHolder> {

    public ApproveStateAdapter(@Nullable List<ApproveState.DataBean.ReviewStatusBean> data) {
        super(R.layout.item_approve_state_list, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ApproveState.DataBean.ReviewStatusBean reviewStatusBean) {
        if (baseViewHolder.getLayoutPosition() == 0) {
            baseViewHolder.setVisible(R.id.view, false);
        } else {
            baseViewHolder.setVisible(R.id.view, true);
        }
        baseViewHolder.setText(R.id.tv_name, reviewStatusBean.getNickName());
        TextView textView = baseViewHolder.getView(R.id.tv_state);
        WorkUtil.approveStateParse(mContext, reviewStatusBean.getOpType(), textView);
        if (reviewStatusBean.getCreateTime() != null) {
            baseViewHolder.setText(R.id.tv_time, reviewStatusBean.getCreateTime());
        }
        ImageView imageView = baseViewHolder.getView(R.id.iv_avatar);
        Glide.with(mContext)
                .load(reviewStatusBean.getAvatar())
                .transform(new GlideCircleTransform(mContext))
                .into(imageView);

    }
}
